package com.baizhi.service.impl;

import com.baizhi.dao.CmfzAlbumDao;
import com.baizhi.entity.CmfzAlbum;
import com.baizhi.service.CmfzAlbumService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
@Transactional
public class CmfzAlbumServiceImpl implements CmfzAlbumService {
    @Autowired
    private CmfzAlbumDao cmfzAlbumDao;

    @Override
    public void inserCmfzAlbum(CmfzAlbum cmfzAlbum) {
        cmfzAlbumDao.insert(cmfzAlbum);
    }

    @Override
    public void deleteCmfzAlbum(Integer id) {
        cmfzAlbumDao.deleteById(id);
    }

    @Override
    @Transactional(readOnly = true)
    public CmfzAlbum selectById(Integer id) {
        return cmfzAlbumDao.selectById(id);
    }

    @Override
    public void updateCmfzAlbum(CmfzAlbum cmfzAlbum) {
        cmfzAlbumDao.updateById(cmfzAlbum);
    }

    @Override
    @Transactional(readOnly = true)
    public Page<CmfzAlbum> selectByPage(Integer page, Integer limit) {
        Page<CmfzAlbum> cmfzAlbumPage = new Page<>(page, limit);
        return cmfzAlbumDao.selectPage(cmfzAlbumPage,null);
    }

    @Override
    @Transactional(readOnly = true)
    public List<CmfzAlbum> selectAll() {
        return cmfzAlbumDao.selectList(null);
    }
}
